package com.cosc716.restaurant.commands.orders;

import com.cosc716.restaurant.commands.Command;
import com.cosc716.restaurant.domain.Order;
import com.cosc716.restaurant.domain.collections.OrderQueue;
import com.cosc716.restaurant.system.Aggregator;

public class CommandRemoveOrder implements Command {
	
	private Order newItem = null;
	
	public CommandRemoveOrder(Order newItem) {
		super();
		this.newItem = newItem;
	}

	@Override
	public Object execute(Aggregator aggregator) {
		if(newItem == null) {
			return new Boolean(false);
		}

		Boolean status;
		
		OrderQueue orders =  aggregator.getOrders();
		if (orders.removeOrder(newItem)) {
			status = new Boolean(true);
		}
		else {
			status = new Boolean(false);
		}
		
		return status;
	}

}
